/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package app;

import ui.Page;

/**
 *
 * @author Administrator
 */
public class AgentDrawer {

    public void draw(String str_url,Page page) {
        java.io.InputStream inputstream = null;
        inputstream = getClass().getResourceAsStream(str_url);
        
        try {
            StringBuffer sb = new StringBuffer();
            int chr, i = 0;
            while((chr = inputstream.read())!=-1) {
                sb.append((char) chr);
            }
            
            ParagrahpElement ap;
            if(sb.length()>0) {
                ap = new ParagrahpElement(sb.toString(), 0, Utils.getPageStart(), page.getWidth(), 0, 0);
                page.addElement(ap);
            } else {
                ap = new ParagrahpElement("Failed", 0, Utils.getPageStart(), page.getWidth(), 0, 0);
                page.addElement(ap);
            }

        } catch(Exception e) {
            e.printStackTrace();
        }

    }
}
